export default {
  data() {
    return {
      feedback: '',
    }
  },
  computed: {
    num() {
      return this.feedback.length
    },
  },
  onLoad() {},
  methods: {
    submit() {
      if (this.num === 0) {
        uni.showToast({
          title: '意见内容不能为空',
          icon: 'none',
        })
        return
      }

      try {
        const res = this.$api.user.addComplaint({
          Content: this.feedback,
        })
        uni.showToast({
          title: '提交成功',
          duration: 2000,
        })
        setTimeout(() => {
          uni.navigateBack({
            delta: 1,
          })
        }, 2000)
      } catch (e) {
        //TODO handle the exception
      }
    },
  },
}
